﻿<%@ Page Language="C#" MasterPageFile="~/Navigations.Master" AutoEventWireup="true" CodeBehind="WxBaseInfoManager.aspx.cs" Inherits="WeChat.Manager.WxBaseInfoManager" Title="微信基础设置" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../bootstrap-3.3.5-dist/js/jquery-1.11.3.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
    $(function(){
        $("[data-toggle='tooltip']").tooltip();
        getBaseInfo();
        //微信基础配置    
        $("#saved").on("click",function(){
            $("input.form-control").each(function(){
            debugger
                if($(this).val()==""){
                    $(this).parents("[for='parent']").addClass("has-error");
                }else{
                    $(this).parents("[for='parent']").removeClass("has-error");
                }
            });
            var err=0;
            if($("#token").val()==""){             
             $("#tokenRe").text("token不能为空");  err++;          
            } else{
              $("#tokenRe").text("");  
            }
            if($("#EncodingAESKey").val()==""){            
             $('#EncodingAESKeyRe').text("消息加密解密密钥不能为空");err++;          
            }else{
              $('#EncodingAESKeyRe').text("");   
            }
            if($("#appId").val()=="") {          
             $('#appIdRe').text("appId不能为空");err++;
            }else{
             $('#appIdRe').text("");   
            }  
            if($("#appSecret").val()==""){
             $('#appSecretRe').text("appSecret不能为空");err++;
            }else{
             $('#appSecretRe').text("");   
            }
            if(err>0)return;
            var param={
             funcName:"setWechatBaseInfo",
             token:$("#token").val(),
             EncodingAESKey:$("#EncodingAESKey").val(),
             appId:$("#appId").val(),
             appSecret:$("#appSecret").val()
            };
            $.post("../WxHandler.ashx",param,function(data){
                if(data=="1"){
                   alert("配置成功！");
                }else{
                   alert("配置失败！");
                }
            });
        });
    });
    function tips(){
         $("#myTip").modal("show");
    } 
    function getBaseInfo(){
        $.ajax({
            type:'post',
            url:'../WxHandler.ashx',
            data:{funcName:'getWechatBaseInfo'},
            success: function (data) {
                debugger
                if(data==null)return;
                data =$.parseJSON(data);
                var item=$.parseJSON(data.baseInfo);
                $("#token").val(item[0].token);
                $("#EncodingAESKey").val(item[0].EncodingAESKey);
                $("#appId").val(item[0].appId);
                $("#appSecret").val(item[0].appSecret);
                $("#url").val("http://"+data.domainName+"/Default.aspx");
            }
        });
    }
    
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="container">
    <div class="panel panel-info">
       <div class="panel-heading">
          <h3 class="panel-title">微信基础配置</h3>
       </div>
       <div class="panel-body">
       <form class="form-horizontal" role="form">
	        <%--<div class="form-group">
		        <label class="col-sm-5 control-label">微信后台地址</label>
		        <div class="col-sm-5">
			        <a href="https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN" target="_Blank">https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN</a> <br />→ 选择 基本配置 → 启用服务器
		        </div>
	        </div>--%>
	        <div class="form-group">
		        <label class="col-sm-3 control-label">URL(服务器地址)</label>
		        <div class="col-sm-7">
			        <%--<span style="color:#338ECF" data-toggle="tooltip" data-placement="top" title="开发者模式接入时填写的服务器地址">http://请在web.config文件中配置该域名/Default.aspx</span>--%>
			        <input type="text" class="form-control " id="url" data-toggle="tooltip" data-placement="top" title="开发者模式接入时填写的服务器地址" placeholder="请在web.config文件中配置该域名" value="http://请在web.config文件中配置该域名/Default.aspx" readonly="readonly"/>
		        </div>
	        </div>
	        
	        <div for="parent" class="form-group">
		        <label class="col-sm-3 control-label">token</label>
		        <div class="col-sm-7">
			        <input type="text" class="form-control" id="token" data-toggle="tooltip" data-placement="top" title="开发者模式接入时填写的token值" placeholder="请输入token" value=""/>
		        </div><span style="color:Red" id="tokenRe"></span>
	        </div>
	        <div for="parent" class="form-group">
		        <label class="col-sm-3 control-label">消息加密解密密钥</label>
		        <div class="col-sm-7">
			        <input type="text" class="form-control" id="EncodingAESKey" data-toggle="tooltip" data-placement="top" title="开发者模式接入时选择加密模式的密钥EncodingAESKey" value=""
				           placeholder="请输入消息加密解密密钥"/><span style="color:Red" id="EncodingAESKeyRe"></span>
		        </div>
	        </div>
	        <div for="parent" class="form-group">
		        <label class="col-sm-3 control-label">appID</label>
		        <div class="col-sm-7">
			        <input type="text" class="form-control" id="appId" data-toggle="tooltip" data-placement="top" title="公众号appID" value=""
				           placeholder="请输入公众号appID"/><span style="color:Red" id="appIdRe"></span>
		        </div>
	        </div>
	        <div for="parent" class="form-group">
		        <label class="col-sm-3 control-label">appSecret</label>
		        <div class="col-sm-7">
			        <input type="text" class="form-control" id="appSecret" data-toggle="tooltip" data-placement="top" title="公众号appSecret" value=""
				           placeholder="请输入公众号appSecret"/><span style="color:Red" id="appSecretRe"></span>
		        </div>
	        </div>
	    </form>
       </div>
       <div class="panel-footer text-left">
        <button type="button" id="saved" class="btn btn-primary">保 存</button>
       </div>
    </div>
</div> 
   <!--rating modal's content-->
<div class="modal fade" id="myTip" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
          <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4>提示</h4>
            </div><!--Modal header-->
            <div class="modal-body"><h3><span id="notes"></span></h3>
            </div><!--Modal body-->
            <div class="modal-footer">
              <a href="#" class="btn btn-default" data-dismiss="modal" >关闭</a>
            </div><!--Modal footer-->
      </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</asp:Content>

